import  pytest
import time
from playwright.sync_api import sync_playwright
class Test_Playwright():
    @pytest.fixture(autouse=True)
    def driver(self):
        self.playwright=sync_playwright().start()
        self.brower=self.playwright.chromium.launch(headless=False)
        self.context=self.brower.new_context()
        self.page=self.context.new_page()
        yield
        self.brower.close()
        self.playwright.stop()
    def test_01(self):
        self.page.goto('https://www.jiuxian.com/')
        self.page.click('a[class="headerLogin"]')
        self.page.fill('input[id="userName"]', '15235688537')
        self.page.fill('input[id="password"]', 'Aa123123')
        time.sleep(10)
        self.page.click('input[id="save"]')
        self.page.click('a[id="bindSub"]')
        time.sleep(3)
        # page.click('xpath=/html/body/div[2]/div/div[2]/ul/li[1]/div[1]/a')
        self.page.goto('https://member.jiuxian.com/index.htm')
        time.sleep(3)
        self.page.click('xpath=/html/body/div[8]/div/div/span')
        time.sleep(2)
        self.page.evaluate('window.scrollTo(0,800)')
        time.sleep(2)
        self.page.click('xpath=/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span')
        time.sleep(3)
        time.sleep(10)

if __name__ == '__main__':
    pytest.main()